package com.help.knowhelps.ui;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.help.knowhelps.cache.Cache;
import com.help.knowhelps.cache.FileCache;
import com.help.knowhelps.utility.Task;
import com.help.knowhelps.view.ProgressNotification;

import android.content.Context;


public class KidsModeContext {
	public static final String RECOMMAND_APP_LIST_CACHE_KEY = "000";// 第一次联网获取的推荐应用列表
	public static final String ALL_CATEGORY_LIST_CACHE_KEY = "001";// 第一次联网获取的分类列表
	public static final String ALL_INSTALLLED_APP_LIST_CACHE_KEY = "002";// 所有已安装应用列表(保持和当前系统同步)
	public static final String DOWANLOAD_FILE_LIST_KEY = "004"; // 下载文件列表
	public static final String INSTALL_FROM_SDK_APP_LIST_KEY = "005"; // 从推荐安装的应用列表
	public static final String INSTALL_APP_CHILD_LIST_KEY = "006"; // 安装应用、孩子对应表
	private static Context sContext = null;
	
	private static Cache sFileCache;
	private static Cache sObjectCache;
	
	private static final String FILE_CACHE_DIR = "file";//文件缓存
	private static final String OBJECT_CACHE_DIR = "obj";//对象缓存
	
	//通知栏进度管理
	private static Map<String, ProgressNotification> sNotificationMap;
	
	//任务管理
	private static Map<String, Task> sTaskMap; 
	
	//任务键
	private static List<String> mKeylist;
	
	//记录本机应用状态（新建孩子时，清除:设置宝宝年龄时）
	public static ArrayList<Object> mApps = new ArrayList<Object>();
		
	public static synchronized void setContext(Context app) {
		sContext = app;
	}
	
	public static Context getContext() {
		return sContext;
	}
	
	/**
	 * 文件缓存
	 * @param context
	 * @return
	 */
	public static synchronized Cache getFileCache(Context context) {
		if (sFileCache == null) {
			sFileCache = new FileCache(context, FILE_CACHE_DIR);
		}

		return sFileCache;
	}
	
	/**
	 * 对象缓存
	 * @param context
	 * @return
	 */
	public static synchronized Cache getObjectCache(Context context) {
		if (sObjectCache == null) {
			sObjectCache = new FileCache(context, OBJECT_CACHE_DIR);
		}

		return sObjectCache;
	}
	
	/**
     * 用于管理通知栏进度
     * @return
     */
    public static synchronized Map<String, ProgressNotification> getNotificationMap(){
    	if(null == sNotificationMap)
    		sNotificationMap =  new HashMap<String, ProgressNotification>();
    	
    	return sNotificationMap;
    }
    
    /**
	 * 用于管理任务
	 * @return
	 */
    public static synchronized Map<String, Task> getTaskMap(){
    	if(null == sTaskMap){
    		sTaskMap = new HashMap<String, Task>();
    	}
    	return sTaskMap;
    }
    
    /**
	 * 用于管理键值
	 * @return
	 */
    public static synchronized List<String> getKeyList(){
    	if(null == mKeylist){
    		mKeylist = new ArrayList<String>();
    	}
    	return mKeylist;
    }
}
